package utils;

import java.io.File;
import java.io.IOException;

public class Logger {
	
	private final static File lockFile = new File("log/.lock");
	
	public static void log(String context, String msg) {
		System.out.println(context + ":: " + msg);
		Utils.writeFile(new File("log/" + context + "_log"), msg);
	}

	public static void startProcess() {
		if(!lockFile.exists())
			try {
				lockFile.createNewFile();
			} catch (IOException e) {
				throw new RuntimeException("EE: Cannot create lock file");
			}
	}

	public static void endProcess() {
		if(lockFile.exists())
				lockFile.delete();
	}
}
